#!/usr/bin/env python

# preshrunk-cotton
# Copyright (C) 2010, 2011 Approximatrix, LLC
# http://code.google.com/p/preshrunk-cotton/
# http://approximatrix.com/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# A full version of the license terms is available in LICENSE.


from pscotton import *
from optparse import OptionParser

if __name__ == "__main__":
    
    
    parser = OptionParser(usage="usage: %prog [options] source_directory [destination_directory]")
    parser.add_option("--disable-toc",
                      action="store_false",
                      dest="build_toc",
                      default=True,
                      help="disable generation of the table of contents")
                      
    parser.add_option("--toc-file",
                      action="store",
                      dest="tocspec",
                      default=None,
                      help="specify a simple table of contents file")
    
    parser.add_option("--disable-index",
                      action="store_false",
                      dest="build_index",
                      default=True,
                      help="disable generation of the index")
    
    parser.add_option("-t", "--title",
                      action="store", # optional because action defaults to "store"
                      dest="title",
                      default=None,
                      help="specifies the CHM file's title")
     
    parser.add_option("-f", "--first_page",
                      action="store", # optional because action defaults to "store"
                      dest="first_page",
                      default=None,
                      help="specifies the first page of the CHM file")
    
    (options, args) = parser.parse_args()


    if len(args) < 1:
        parser.print_help()
    else:
        input = args[0]
        output = None
        if(len(args) >= 2):
            output = args[1]
            
        tt2chm(input, output, chm_index=options.build_index, 
               chm_toc=options.build_toc, 
               first_page=options.first_page,
               title=options.title,
               tocspec=options.tocspec)
        
